#include <bits/stdc++.h>
using namespace std;
int n;
const int maxn = 12;
bool row[maxn];
int color[maxn], diag[2 * maxn], backdiag[2 * maxn];
char disp[maxn][maxn];
void show() {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      disp[i][j] = '.';
    }
    disp[i][n] = 0;
  }
  for (int i = 0; i < n; ++i) {
    disp[i][color[i]] = 'Q';
    puts(disp[i]);
  }
  putchar('\n');
}
void dfs(int dep) {
  if (dep == n) {
    show();
    return;
  }
  for (int i = 0; i < n; ++i) {
    if (row[i] || diag[n - 1 - dep + i] || backdiag[dep + i]) continue;
    row[i] = diag[n - 1 - dep + i] = backdiag[dep + i] = true;
    color[dep] = i;
    dfs(dep + 1);
    row[i] = diag[n - 1 - dep + i] = backdiag[dep + i] = false;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    color[0] = i;
    row[i] = true;
    diag[n - 1 - 0 + i] = true;
    backdiag[i] = true;
    dfs(1);
    row[i] = false;
    diag[n - 1 - 0 + i] = false;
    backdiag[i] = false;
  }
}
